package online.shenjian.mq;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

@Component
@ConditionalOnProperty(name = "spring.rabbitmq.enable", matchIfMissing = true)
public class DirectSender {

    private RabbitTemplate rabbitTemplate;

    public DirectSender(RabbitTemplate rabbitTemplate) {
        this.rabbitTemplate = rabbitTemplate;
    }

    public void send() {
        rabbitTemplate.convertAndSend("direct", "orange", "orange msg");
        rabbitTemplate.convertAndSend("direct", "green", "green msg");
        rabbitTemplate.convertAndSend("direct", "black", "black msg");
    }
}
